import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserInfoStore = defineStore(
  'userInfo',
  () => {
    /**用户信息 */
    const userInfo = ref()
    /**修改用户信息 */
    const setUserInfo = (val) => {
      userInfo.value = val
    }
    /**删除用户信息 */
    const deleteUserInfo = () => {
      userInfo.value = undefined
    }
    /** token */
    const token = ref()
    /**修改token */
    const setToken = (val) => {
      token.value = val
    }
    /**删除token */
    const deleteToken = () => {
      token.value = undefined
    }

    return {
      userInfo,
      setUserInfo,
      deleteUserInfo,
      token,
      setToken,
      deleteToken,
    }
  },

  {
    // 数据持久化
    persist: true,
  },
)
